package qlvbdq.bo;

import java.sql.SQLException;
import qlvbdq.dao.HangGiaCongDAO;
import qlvbdq.dto.HangGiaCongDTO;

/**
 *
 * @author THAI HA
 */
public class HangGiaCongBO {

    public HangGiaCongBO() {
    }

    public boolean insertHangGiaCong(HangGiaCongDTO hgcdto_) {
        return new HangGiaCongDAO().insertHangGC(hgcdto_) > 0;
    }

    public boolean deleteHangGiaCong(String maHangGiaCong_) {
        return new HangGiaCongDAO().deleteHangGCByMa(maHangGiaCong_) > 0;
    }

    public boolean updateHangGiaCong(HangGiaCongDTO hgcdto_) {
        return new HangGiaCongDAO().updateHangGC(hgcdto_) > 0;
    }

    public HangGiaCongDTO getHangGiaCong(String maHangGiaCong_) {
        try {
            return new HangGiaCongDAO().getHangGiaCongByMaHGC(maHangGiaCong_);
        } catch (SQLException ex) {
            System.out.println("Không thể xử lý mã hàng này!" + maHangGiaCong_);
            return null;
        }
    }
    
    public String getNewMaHangGiaCong(){
        try {
            return new HangGiaCongDAO().getNewMaHangGC();
        } catch (SQLException ex) {
            System.out.println("Tạo mã mới thất bại");
            return null;
        }
    }
}
